package model

import (
	"common/globals"
	"gorm.io/gorm"
)

/*积分流水表*/

type IntegralFlow struct {
	gorm.Model
	UserId                     int    `gorm:"column:user_id;type:int;not null" json:"user_id"`                                           //用户编号
	ControlsType               int    `gorm:"column:controls_type;type:int;not null" json:"controls_type"`                               // 1 支出  2收入
	IntegrationBeforeOperation int    `gorm:"column:integration_before_operation;type:int;not null" json:"integration_before_operation"` //操作前积分
	OperationIntegral          int    `gorm:"column:operation_integral;type:int;not null" json:"operation_integral"`                     //积分
	IntegrationAfterOperation  int    `gorm:"column:integration_after_operation;type:int;not null" json:"integration_after_operation"`   //操作后积分
	OperationalReasons         string `gorm:"column:operational_reasons;type:varchar(80)" json:"operational_reasons"`                    //操作原因
}

func (i *IntegralFlow) TableName() string {
	return "integral_flow"
}
func (i *IntegralFlow) Create() error {
	return globals.Db.Create(&i).Error
}
